package MaintMenu.PoAnalysis;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   LTAnalysis.java

import java.sql.*;

// Referenced classes of package pk1:
//            DnkFunctions

public class LTAnalysis {

    public LTAnalysis(String from, String to) {
        try {
            DnkFunctionslt dnk = new DnkFunctionslt();
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            Statement st1 = con.createStatement();
            Statement st2 = con.createStatement();
            try {
                st.execute("DELETE * FROM TBLDRSALE;");
                st.execute("DELETE * FROM TBLDRSALE1;");
                st.execute("DELETE * FROM TBLDRSALE2;");
                st.execute((new StringBuilder()).append("INSERT INTO TBLDRSALE1([PART#],DRSALE) SELECT C.[PART#], SUM(C.QUANTITY) AS DRSale FROM TBLARINVOICES AS B INNER JOIN TBLARINVOICEDETAIL AS C ON B.ARINVOICEID=C.ARINVOICEID WHERE (B.[DATE] BETWEEN #").append(from).append("# AND #").append(to).append("#) ").append("AND (NOT EXISTS (SELECT * FROM TBLCUSTOMERS A ").append("WHERE B.CUSTOMERID=A.CUSTOMERID AND ").append("A.[CUST#] IN('DNK333','DNK777'))) ").append("AND (NOT ISNULL(C.[PART#])) GROUP BY C.[PART#];").toString());
                st.execute((new StringBuilder()).append("INSERT INTO TBLDRSALE2([PART#],DRSALE) SELECT C.[PART#], SUM(C.QUANTITY) AS DRSale FROM TBLARINVOICESB AS B INNER JOIN TBLARINVOICEDETAILB AS C ON B.ARINVOICEID=C.ARINVOICEID WHERE (B.[DATE] BETWEEN #").append(from).append("# AND #").append(to).append("#) ").append("AND (NOT EXISTS (SELECT * FROM TBLCUSTOMERSB A ").append("WHERE B.CUSTOMERID=A.CUSTOMERID AND ").append("A.[CUST#] IN('DNK333','DNK777'))) ").append("AND (NOT ISNULL(C.[PART#])) GROUP BY C.[PART#];").toString());
                st.execute("INSERT INTO TBLDRSALE([PART#],DRSALE) SELECT [PART#],0 FROM TBLINVENTORY;");
                st.execute("UPDATE TBLDRSALE A INNER JOIN TBLDRSALE1 B ON A.[PART#] = B.[PART#] SET A.DRSALE=A.DRSALE+B.DRSALE;");
                st.execute("UPDATE TBLDRSALE A INNER JOIN TBLDRSALE2 B ON A.[PART#] = B.[PART#] SET A.DRSALE=A.DRSALE+B.DRSALE;");
//                st.execute("INSERT INTO TBLLTN ( [PART#], SUPPLIER, DESCRIPTION, t24m, t12m, 12MSL, 9msl, 6MSL, 3MSL, RATE, INSTOCK, 1mns, 1M, 1_5M, 2M, 3M, 4M, 5M, ONORDER, SHIPPING, GD, GENERA, DEPO, ee, REMARK, DNK_MEMO, GD_MEMO, GENERA_MEMO, DEPO_MEMO, EE_MEMO, NEW, GD_P, GENERA_P, DEPO_P, ee_p, GD_K, GENERA_K, DEPO_K, EE_K, [GD#], [GENERA#], [DEPO#], [EE#], GD_C, GENERA_C, DEPO_C, EE_C, GD_BO, GENERA_BO, DEPO_BO, EE_BO, OEM_NO, PARTLINK, SUGGEST, CAPA ) SELECT ITEM_NO, SUPPLIER, DESCRIPT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, REMARK, GD_REMARK, NULL, NULL, NULL, 0, IIF(ISNULL(GD_PRC),0,GD_PRC), IIF(ISNULL(TYC_PRC),0,TYC_PRC), IIF(ISNULL(DEPO_PRC),0,DEPO_PRC), IIF(ISNULL(EAGLEPRC),0,EAGLEPRC), IIF(ISNULL(GD_PKG),0,GD_PKG), IIF(ISNULL(TYC_PKG),0,TYC_PKG), IIF(ISNULL(DEPO_PKG),0,DEPO_PKG), IIF(ISNULL(EAGLEPKG),0,EAGLEPKG), GD_NO, TYC_NO, DEPO_NO, EAGLE_NO, IIF(ISNULL(GD_CUFT),0,GD_CUFT), 0, 0, 0, 0, 0, 0, 0, OEM_NO, PARTLINK, 0, IIF(CAPA = 'Y',-1,0) FROM LT_MAST1 WHERE ITEM_NO NOT IN (SELECT [PART#] FROM TBLLTN);");
                st.execute("UPDATE TBLLTN SET T24M = 0, T12M = 0, 12MSL = 0, 9MSL = 0, 6MSL = 0, 3MSL = 0, INSTOCK = 0, 1MNS = 0, 1M = 0, 1_5M = 0, 2M = 0, 3M = 0, 4M = 0, 5M = 0, 6M = 0, ONORDER = 0, SHIPPING = 0, GD = 0, GENERA = 0, DEPO = 0, EE = 0, REMARK = NULL, NEW = 0, SUGGEST = 0, start5 = 0, high5 = 0, avg5 = 0, start4 = 0, high4 = 0, avg4 = 0;");
                st.execute("UPDATE TBLLTN AS A INNER JOIN TBLINVENTORY AS B ON A.[PART#]=B.[PART#] SET A.DESCRIPTION = B.DESCRIPTION WHERE A.DESCRIPTION <> B.DESCRIPTION OR ISNULL(A.DESCRIPTION);");
                st.execute("UPDATE TBLLTN AS A INNER JOIN TBLINVENTORY AS B ON A.[PART#]=B.[PART#] SET A.POSITION = B.POSITION WHERE A.POSITION <> B.POSITION OR ISNULL(A.POSITION);");
                st.execute("UPDATE TBLLTN SET GENERA_K = 0 WHERE ISNULL(GENERA_K);");
                st.execute("UPDATE TBLLTN SET DEPO_K = 0 WHERE ISNULL(DEPO_K);");
                st.execute("UPDATE TBLLTN SET GD_K = 0 WHERE ISNULL(GD_K);");
                st.execute("UPDATE (TBLLTN AS A LEFT JOIN TBLSUMSALE AS B ON A.[PART#]=B.[PART#]) LEFT JOIN TBLSUMSALE1 AS C ON A.[PART#]=C.[PART#] SET A.12MSL = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]) + IIF(ISNULL(C.[12MSL]),0,C.[12MSL]) - (IIF(ISNULL(B.[9MSL]),0,B.[9MSL]) + IIF(ISNULL(C.[9MSL]),0,C.[9MSL])), A.3MSL = IIF(ISNULL(B.[3MSL]),0,B.[3MSL]) + IIF(ISNULL(C.[3MSL]),0,C.[3MSL]), A.6MSL = IIF(ISNULL(B.[6MSL]),0,B.[6MSL]) + IIF(ISNULL(C.[6MSL]),0,C.[6MSL]) - (IIF(ISNULL(B.[3MSL]),0,B.[3MSL]) + IIF(ISNULL(C.[3MSL]),0,C.[3MSL])), A.9MSL = IIF(ISNULL(B.[9MSL]),0,B.[9MSL]) + IIF(ISNULL(C.[9MSL]),0,C.[9MSL]) - (IIF(ISNULL(B.[6MSL]),0,B.[6MSL]) + IIF(ISNULL(C.[6MSL]),0,C.[6MSL])), A.T24M = IIF(ISNULL(B.[24MSL]),0,B.[24MSL]) + IIF(ISNULL(C.[24MSL]),0,C.[24MSL]) - (IIF(ISNULL(B.[12MSL]),0,B.[12MSL]) + IIF(ISNULL(C.[12MSL]),0,C.[12MSL])), A.T12M = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]) + IIF(ISNULL(C.[12MSL]),0,C.[12MSL]);");
                st.execute("UPDATE TBLLTN AS A INNER JOIN TBLINVENTORY AS B ON A.[PART#]=B.[PART#] SET A.INSTOCK = B.INSTOCK+B.INSTOCK1, A.RATE = [3MSL]-[6MSL];");
                st.execute("DELETE * FROM tblonorder;");
                st.execute("INSERT INTO TBLONORDER ( [PART#], ONORDER ) SELECT [PART#], SUM(QTY-SHIPPED) AS ONORDER FROM TBLTEMPPO1 GROUP BY [PART#];");
                st.execute("UPDATE TBLLTN AS a INNER JOIN tblonorder AS b ON a.[part#] = b.[part#] SET a.onorder = B.ONORDER;");
                st.execute("DELETE * FROM TBLSHIPPING;");
                st.execute("INSERT INTO TBLSHIPPING ( [PART#], SHIPPING ) SELECT B.[PART#], SUM(B.amountout) AS SHIPPING FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND PRINTED = -1 GROUP BY B.[PART#];");
                st.execute("UPDATE TBLLTN AS A INNER JOIN TBLSHIPPING AS B ON A.[PART#]=B.[PART#] SET A.SHIPPING = B.SHIPPING;");
                st.execute("SELECT B.[PART#] AS PART, B.CONTAINER AS CON FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND B.AMOUNTOUT <> 0;");
                ResultSet rs = st.getResultSet();
                if (rs != null)
                    while (rs.next()) {
                        String a = rs.getString("CON");
                        String b = rs.getString("PART");
                        try {
                            st2.execute((new StringBuilder()).append("update TBLLTN set REMARK = REMARK & ' ' & '").append(a).append("' WHERE [PART#] = '").append(b).append("';").toString());
                        } catch (SQLException er) {
                        }
                    }
                st.execute("UPDATE TBLLTN SET 1MNS = IIF(IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6)>[3MSL]/3, IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6), [3MSL]/3);");
                st.execute("UPDATE TBLLTN SET high5 = [1mns]*1.25");
                st.execute("UPDATE TBLLTN SET avg5 = high5/5");
                st.execute("UPDATE TBLLTN SET high4 = [1mns]");
                st.execute("UPDATE TBLLTN SET avg4 = high4/4");
                st.execute("UPDATE TBLLTN SET 1M = iif(instock>0,INSTOCK,0) - [1MNS], 1_5M = iif(instock>0,INSTOCK,0) - [1MNS]*1.5, 2M = iif(instock>0,INSTOCK,0) - [1MNS]*2, 3M = iif(instock>0,INSTOCK,0) - [1MNS]*3, 4M = iif(instock>0,INSTOCK,0) - [1MNS]*4, 5M = iif(instock>0,INSTOCK,0) - [1MNS]*5, 6M = iif(instock>0,INSTOCK,0) - [1MNS]*6;");
                st.execute("DELETE * FROM TBLMINCOSTINGDATE;");
                st.execute("INSERT INTO TBLMINCOSTINGDATE ( INVID, RDATE ) SELECT INVID, MIN(DATERECEIVED) AS RDATE FROM TBLINVENTORYCOSTING GROUP BY INVID;");
                st.execute("UPDATE TBLLTN AS A INNER JOIN (TBLINVENTORY AS B INNER JOIN TBLMINCOSTINGDATE AS C ON B.INVID=C.INVID) ON A.[PART#]=B.[PART#] SET A.NEW = IIF((C.RDATE >= DATEADD('M',-3,NOW())) AND (B.BEGINYR >= DATEPART('YYYY',DATEADD('YYYY',-4,NOW()))),-1,0);");
                st.execute("DELETE * FROM TBLLTN_TEMP;");
                st.execute("INSERT INTO TBLLTN_TEMP SELECT * FROM TBLLTN;");
                st.execute("UPDATE TBLLTN_temp SET 1MNS = IIF([1MNS] >= 0.1 OR [1MNS] <= -0.1,Round([1MNS], 0), 0), 1M = IIF([1M] >= 0.1 OR [1M] <= -0.1,Round([1M], 0),0), 1_5M = IIF([1_5M] >= 0.1 OR [1_5M] <= -0.1,ROUND([1_5M], 0), 0), 2M = IIF([2M] >= 0.1 OR [2M] <= -0.1,ROUND([2M],0), 0), 3M = IIF([3M] >= 0.1 OR [3M] <= -0.1,ROUND([3M],0), 0), 4M = IIF([4M] >= 0.1 OR [4M] <= -0.1, ROUND([4M],0), 0), 5M = IIF([5M] >= 0.1 OR [5M] <= -0.1,ROUND([5M],0), 0), 6M = IIF([6M] >= 0.1 OR [6M] <= -0.1,ROUND([6M],0), 0);");
                st.execute("UPDATE TBLLTN_temp SET avg5 = Round(avg5,0), high5= Round(high5,0)");
                st.execute("UPDATE TBLLTN_temp SET start5 = high5+avg5");
                st.execute("UPDATE TBLLTN_temp SET avg4 = Round(avg4,0), high4= Round(high4,0)");
                st.execute("UPDATE TBLLTN_temp SET start4 = high4+avg4");
                st.execute("select * from tblltn_temp;");
                ResultSet rs1 = st.getResultSet();
                if (rs1 != null) {
                    double genera_p = 0.0D;
                    double depo_p = 0.0D;
                    double gd_p = 0.0D;
                    double high5 = 0.0D;
                    double high4 = 0.0D;
                    double avg5 = 0.0D;
                    double avg4 = 0.0D;
                    double instock = 0.0D;
                    int onorder = 0;
                    int shipping = 0;
                    int genera_bo = 0;
                    int depo_bo = 0;
                    int gd_bo = 0;
                    int t12m = 0;
                    double needBuy = 0.0D;
                    double needBuya = 0.0D;
                    double needBuy4 = 0.0D;
                    double needBuyb = 0.0D;
                    String bc = "null";
                    String part = "null";
                    String supplier = "null";
                    while (rs1.next()) {
                        genera_p = rs1.getDouble("genera_p");
                        depo_p = rs1.getDouble("depo_p");
                        gd_p = rs1.getDouble("gd_p");
                        high5 = rs1.getDouble("high5");
                        high4 = rs1.getDouble("high4");
                        avg5 = rs1.getDouble("avg5");
                        avg4 = rs1.getDouble("avg4");
                        instock = rs1.getDouble("instock");
                        onorder = rs1.getInt("onorder");
                        shipping = rs1.getInt("shipping");
                        genera_bo = rs1.getInt("genera_bo");
                        depo_bo = rs1.getInt("depo_bo");
                        gd_bo = rs1.getInt("gd_bo");
                        t12m = rs1.getInt("t12m");
                        if (instock < 0.0D)
                            instock = 0.0D;
                        supplier = rs1.getString("supplier");
                        if (supplier == null)
                            supplier = " ";
                        needBuy4 = high4 - instock - (double) onorder - (double) shipping - (double) genera_bo - (double) depo_bo - (double) gd_bo;
                        needBuyb = (high4 + avg4) - instock - (double) onorder - (double) shipping - (double) genera_bo - (double) depo_bo - (double) gd_bo;
                        bc = dnk.comparePrice(genera_p * 0.97499999999999998D, depo_p, 0.0D, 0.0D, 0.0D, 0.0D, supplier);
                        part = rs1.getString("part#");
                        if (bc.equals("depo") && genera_p > 0.0D && genera_p < depo_p + 1.0D)
                            bc = "gn";
                        if (bc.equals("gn"))
                            try {
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set genera = ").append(needBuyb).append(" where high4 > 0 and ").append("(high4 - instock - onorder - shipping - ").append("genera_bo - depo_bo - gd_bo)>=0 ").append("and t12m > 4 and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp A INNER JOIN TBL2REG B ON A.T12M=B.T12M set A.genera = IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) WHERE A.genera < IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set supplier = '").append(bc).append("' where [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN set supplier = '").append(bc).append("' where [part#] = '").append(part).append("';").toString());
                            } catch (SQLException er) {
                            }
                        else if (bc.equals("gd"))
                            try {
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set gd = ").append(needBuya).append(" where high3 > 0 and ").append("(high3 - instock - onorder - shipping - ").append("genera_bo - depo_bo - gd_bo)>=0 ").append("and t12m > 4 and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp A INNER JOIN TBL4REG B ON A.T12M=B.T12M set A.gd = IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) WHERE A.gd < IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update (TBLLTN_temp A INNER JOIN TBL4NEW B ON A.T12M=B.T12M) INNER JOIN TBLINVENTORY C ON A.[PART#] = C.[PART#] set A.gd = IIF((B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo - A.depo_bo - A.gd_bo)>=0,(B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo -A.depo_bo - A.gd_bo+b.avg),0) WHERE A.gd < IIF((B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo - A.depo_bo - A.gd_bo)>=0,(B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo -A.depo_bo - A.gd_bo+b.avg),0) and C.BEGINYR >= DATEPART('YYYY',DATEADD('YYYY',-2,NOW())) AND A.[part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update (TBLLTN_temp A INNER JOIN TBL4OLD B ON A.T12M=B.T12M) INNER JOIN TBLINVENTORY C ON A.[PART#] = C.[PART#] set A.GD = IIF((B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo - A.depo_bo - A.gd_bo)>=0,(B.ORDER- A.instock - A.onorder - A.shipping -A.genera_bo -A.depo_bo - A.gd_bo+b.avg),0) WHERE C.ENDYR <= DATEPART('YYYY',DATEADD('YYYY',-12,NOW())) AND A.[part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set supplier = '").append(bc).append("' where [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN set supplier = '").append(bc).append("' where [part#] = '").append(part).append("';").toString());
                            } catch (SQLException er) {
                            }
                        else if (bc.equals("depo"))
                            try {
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set depo = ").append(needBuyb).append(" where high4 > 0 and ").append("(high4 - instock - onorder - shipping - ").append("genera_bo - depo_bo - gd_bo)>=0 ").append("and t12m > 4 and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp A INNER JOIN TBL2REG B ON A.T12M=B.T12M set A.depo = IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) WHERE A.depo < IIF((B.ORDER- instock - onorder - shipping -genera_bo - depo_bo - gd_bo)>=0,(B.ORDER- instock - onorder - shipping -genera_bo -depo_bo - gd_bo+b.avg),0) and [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN_temp set supplier = 'd' where [part#] = '").append(part).append("';").toString());
                                st2.execute((new StringBuilder()).append("update TBLLTN set supplier = 'd' where [part#] = '").append(part).append("';").toString());
                            } catch (SQLException er) {
                            }
                        else
                            st2.execute((new StringBuilder()).append("update tblltn_temp set manual=-1 where [part#] = '").append(part).append("';").toString());
                    }
                }
                st.execute("UPDATE TBLLTN_TEMP SET MANUAL = -1 WHERE T12M =[3MSL] AND T12M > 0;");
                st.execute("DELETE * FROM tblltn_tempout;");
                st.execute((new StringBuilder()).append("INSERT INTO tblltn_tempout ( [part#], Supplier, description, rate, t12m, 12msl, 9msl, 6msl, 3msl, instock, onorder, shipping, 1ns, 2m, 3m, 4m, 5m, 6m, start4,high4,avg4,gn, depo, gd, ee, gn_p, depo_p, gd_p, ee_p, gn_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [gn#], [depo#], [gd#], [ee#], remark, oem_no, partlink, gn_k, depo_k, gd_k, ee_k, new, manual, gn_c, depo_c, gd_c, ee_c, capa, position,drsale,drdate ) SELECT [part#], Supplier, description, rate, [t12m], [12msl], [9msl], [6msl], [3msl], instock, onorder, shipping, [1m], [2m]+(onorder+shipping+genera_bo+depo_bo+gd_bo), [3m]+(onorder+shipping+genera_bo+depo_bo+gd_bo), [4m]+(onorder+shipping+genera_bo+depo_bo+gd_bo), [5m]+(onorder+shipping+genera_bo+depo_bo+gd_bo), [6m]+(onorder+shipping+genera_bo+depo_bo+gd_bo), start4,high4,avg4,genera, depo, gd, ee, genera_p, depo_p, gd_p, ee_p, genera_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [genera#], [depo#], [gd#], [ee#], remark, oem_no, partlink, genera_k, depo_k, gd_k, ee_k, new, manual, genera_c, depo_c, gd_c, ee_c, capa, position, 0, '").append(from).append("' ").append("FROM tblltn_temp ").append("ORDER BY genera+depo+GD DESC;").toString());
                st.execute("UPDATE TBLLTN_TEMPOUT A INNER JOIN TBLDRSALE B ON A.[PART#] = B.[PART#] SET A.DRSALE=B.DRSALE;");
                st.execute("DELETE * FROM tblltn_tempoutli;");
                st.execute("INSERT INTO tblltn_tempoutli ([part#], Supplier, description, t24m, t12m, [12msl], [9msl], [6msl], [3msl], instock, overstock, shipping, high4w, [2w], gn, depo, gd, ee, li, bk, gn_p, depo_p, gd_p, ee_p, gn_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [gn#], [depo#], [gd#], [ee#], remark, oem_no, partlink, gn_k, depo_k, gd_k, ee_k, new, manual, gn_c, depo_c, gd_c, ee_c, capa, position, drsale, drdate)SELECT [part#], Supplier, description, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, gn_p, depo_p, gd_p, ee_p, gn_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [gn#], [depo#], [gd#], [ee#], null, oem_no, partlink, gn_k, depo_k, gd_k, ee_k, new, 0, gn_c, depo_c, gd_c, ee_c, capa, position, 0, drdate FROM tblltn_tempout order by gn+depo desc;");
                st.execute("UPDATE tblltn_tempoutli AS a LEFT JOIN tblsumsale AS b ON a.[part#] = b.[part#] SET A.12MSL = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]) - IIF(ISNULL(B.[9MSL]),0,B.[9MSL]), A.3MSL = IIF(ISNULL(B.[3MSL]),0,B.[3MSL]), A.6MSL = IIF(ISNULL(B.[6MSL]),0,B.[6MSL])  - IIF(ISNULL(B.[3MSL]),0,B.[3MSL]), A.9MSL = IIF(ISNULL(B.[9MSL]),0,B.[9MSL]) - IIF(ISNULL(B.[6MSL]),0,B.[6MSL]), A.T12M = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]), A.T24M = IIF(ISNULL(B.[24MSL]),0,B.[24MSL])  - IIF(ISNULL(B.[12MSL]),0,B.[12MSL]);");
                st.execute("UPDATE TBLLTN_TEMPOUTLI SET HIGH4W = IIF(IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6)>[3MSL]/3, IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6), [3MSL]/3);");
                st.execute("UPDATE tblltn_tempoutli SET high4w=Round(HIGH4W,0);");
                st.execute("UPDATE tblltn_tempoutli AS a inner JOIN tblinventory AS b ON a.[part#] = b.[part#] SET a.instock = b.instock, a.beginyr=b.beginyr, a.endyr=b.endyr;");
                st.execute("UPDATE tblltn_tempoutli AS a inner JOIN tbldrsale1 AS b ON a.[part#] = b.[part#] SET a.drsale = b.drsale;");
                st.execute("delete * from TBLSHIPPINGLI;");
                st.execute("INSERT INTO TBLSHIPPINGLI ( [PART#], SHIPPING ) SELECT B.[PART#], SUM(B.amountout) AS SHIPPING FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND PRINTED = -1 AND (B.CONTAINER NOT LIKE '%BK%') GROUP BY B.[PART#];");
                st.execute("UPDATE tblltn_tempoutli AS A INNER JOIN TBLSHIPPINGLI AS B ON A.[PART#]=B.[PART#] SET A.SHIPPING = B.SHIPPING;");
                st.execute("DELETE * FROM TBLSHIPPINGLI1");
                st.execute("INSERT INTO TBLSHIPPINGLI1 (PART,CON) SELECT B.[PART#] AS PART, B.CONTAINER AS CON FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND B.AMOUNTOUT <> 0 AND (B.CONTAINER NOT LIKE '%BK%');");
                st.execute("SELECT * FROM TBLSHIPPINGLI1");
                ResultSet rs4 = st.getResultSet();
                if (rs4 != null)
                    while (rs4.next()) {
                        String a4 = rs4.getString("CON");
                        String b4 = rs4.getString("PART");
                        try {
                            st2.execute((new StringBuilder()).append("update tblltn_tempoutli set REMARK = REMARK & ' ' & '").append(a4).append("' WHERE [PART#] = '").append(b4).append("';").toString());
                        } catch (SQLException er) {
                        }
                    }
                st.execute("select * from tblltn_tempoutli;");
                ResultSet rs2 = st.getResultSet();
                if (rs2 != null) {
                    double gn_p = 0.0D;
                    double depo_p = 0.0D;
                    double gd_p = 0.0D;
                    double high4w = 0.0D;
                    double instock = 0.0D;
                    double shipping = 0.0D;
                    int t12m = 0;
                    int t3msl = 0;
                    double needBuy4 = 0.0D;
                    double need2w = 0.0D;
                    double need2w1 = 0.0D;
                    String bc = "null";
                    String part = "null";
                    String supplier = "null";
                    int n = 0;
                    String beginyr = "null";
                    String endyr = "null";
                    int byr = 0;
                    int eyr = 0;
                    while (rs2.next()) {
                        gn_p = rs2.getDouble("gn_p");
                        depo_p = rs2.getDouble("depo_p");
                        gd_p = rs2.getDouble("gd_p");
                        high4w = rs2.getDouble("high4w");
                        instock = rs2.getDouble("instock");
                        shipping = rs2.getDouble("shipping");
                        t12m = rs2.getInt("t12m");
                        t3msl = rs2.getInt("3msl");
                        supplier = rs2.getString("supplier");
                        n = rs2.getInt("new");
                        beginyr = rs2.getString("beginyr");
                        endyr = rs2.getString("endyr");
                        if (beginyr == null)
                            beginyr = "1900";
                        if (endyr == null)
                            endyr = "1900";
                        byr = Integer.parseInt(beginyr);
                        eyr = Integer.parseInt(endyr);
                        if (supplier == null)
                            supplier = " ";
                        if (instock < 0.0D)
                            instock = 0.0D;
                        bc = dnk.comparePrice(gn_p * 0.97499999999999998D, depo_p, 0.0D, 0.0D, 0.0D, 0.0D, supplier);
                        part = rs2.getString("part#");
                        need2w = dnk.getNeed(t12m);
                        need2w1 = dnk.getNeed1(t12m, byr, eyr, n, t3msl);
                        if (bc.equals("depo") && gn_p > 0.0D && gn_p < depo_p + 1.0D)
                            bc = "gn";
                        try {
                            st2.execute((new StringBuilder()).append("update TBLLTN_tempoutli set [2w] = ").append(need2w).append(" where [part#] = '").append(part).append("';").toString());
                        } catch (SQLException er) {
                        }
                        if (instock + shipping <= need2w)
                            needBuy4 = need2w1 + (need2w - (instock + shipping));
                        else
                            needBuy4 = 0.0D;
                        if (needBuy4 > 0.0D) {
                            if (bc.equals("gn"))
                                try {
                                    st2.execute((new StringBuilder()).append("update TBLLTN_tempoutli set gn = ").append(needBuy4).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            else if (bc.equals("depo"))
                                try {
                                    st2.execute((new StringBuilder()).append("update TBLLTN_tempoutli set depo = ").append(needBuy4).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            else
                                try {
                                    st2.execute((new StringBuilder()).append("update tblltn_tempoutli set manual=-1 where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                        } else if (needBuy4 >= 0.0D) ;
                    }
                }
                st.execute("UPDATE TBLLTN_TEMPOUTLI SET gn = 0 WHERE T12M <= 2 and gn>0 and gn_p >150;");
                st.execute("UPDATE TBLLTN_TEMPOUTLI SET depo = 0 WHERE T12M <= 2 and depo>0 and depo_p >150;");
                st.execute("DELETE * FROM tblltn_tempoutbl;");
                st.execute("INSERT INTO tblltn_tempoutbl ([part#], Supplier, description, t24m, t12m, [12msl], [9msl], [6msl], [3msl], instock, overstock, shipping, high4w, [2w], gn, depo, gd, ee, li, bk, gn_p, depo_p, gd_p, ee_p, gn_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [gn#], [depo#], [gd#], [ee#], remark, oem_no, partlink, gn_k, depo_k, gd_k, ee_k, new, manual, gn_c, depo_c, gd_c, ee_c, capa, position, drsale, drdate)SELECT [part#], Supplier, description, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, gn_p, depo_p, gd_p, ee_p, gn_memo, depo_memo, gd_memo, ee_memo, dnk_memo, [gn#], [depo#], [gd#], [ee#], null, oem_no, partlink, gn_k, depo_k, gd_k, ee_k, new, 0, gn_c, depo_c, gd_c, ee_c, capa, position, 0, drdate FROM tblltn_tempout order by gn+depo desc;");
                st.execute("UPDATE tblltn_tempoutbl AS a LEFT JOIN tblsumsale1 AS b ON a.[part#] = b.[part#] SET A.12MSL = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]) - IIF(ISNULL(B.[9MSL]),0,B.[9MSL]), A.3MSL = IIF(ISNULL(B.[3MSL]),0,B.[3MSL]), A.6MSL = IIF(ISNULL(B.[6MSL]),0,B.[6MSL])  - IIF(ISNULL(B.[3MSL]),0,B.[3MSL]), A.9MSL = IIF(ISNULL(B.[9MSL]),0,B.[9MSL]) - IIF(ISNULL(B.[6MSL]),0,B.[6MSL]), A.T12M = IIF(ISNULL(B.[12MSL]),0,B.[12MSL]), A.T24M = IIF(ISNULL(B.[24MSL]),0,B.[24MSL])  - IIF(ISNULL(B.[12MSL]),0,B.[12MSL]);");
                st.execute("UPDATE TBLLTN_TEMPOUTBL SET HIGH4W = IIF(IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6)>[3MSL]/3, IIF(([3MSL]+[6MSL]+[9MSL]+[12MSL])/12>([3MSL]+[6MSL])/6, ([3MSL]+[6MSL]+[9MSL]+[12MSL])/12, ([3MSL]+[6MSL])/6), [3MSL]/3);");
                st.execute("UPDATE tblltn_tempoutbl SET high4w=Round(HIGH4W,0);");
                st.execute("UPDATE tblltn_tempoutbl AS a inner JOIN tblinventory AS b ON a.[part#] = b.[part#] SET a.instock = b.instock1, a.beginyr=b.beginyr, a.endyr=b.endyr;");
                st.execute("UPDATE tblltn_tempoutbl AS a inner JOIN tbldrsale2 AS b ON a.[part#] = b.[part#] SET a.drsale = b.drsale;");
                st.execute("delete * from TBLSHIPPINGBK;");
                st.execute("INSERT INTO TBLSHIPPINGBK ( [PART#], SHIPPING ) SELECT B.[PART#], SUM(B.amountout) AS SHIPPING FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND PRINTED = -1 AND (B.CONTAINER LIKE '%BK%') GROUP BY B.[PART#];");
                st.execute("UPDATE tblltn_tempoutbl AS A INNER JOIN TBLSHIPPINGBK AS B ON A.[PART#]=B.[PART#] SET A.SHIPPING = B.SHIPPING;");
                st.execute("DELETE * FROM TBLSHIPPINGBK1");
                st.execute("INSERT INTO TBLSHIPPINGBK1(PART,CON) SELECT B.[PART#] AS PART, B.CONTAINER AS CON FROM TBLPURCHASEORDERS AS A INNER JOIN TBLPURCHASEORDERDETAIL AS B ON A.POID=B.POID WHERE A.CLEARED = 0 AND (NOT ISNULL(B.CONTAINER)) AND B.AMOUNTOUT <> 0 AND (B.CONTAINER LIKE '%BK%');");
                st.execute("SELECT * FROM TBLSHIPPINGBK1");
                ResultSet rs5 = st.getResultSet();
                if (rs5 != null)
                    while (rs5.next()) {
                        String a5 = rs5.getString("CON");
                        String b5 = rs5.getString("PART");
                        try {
                            st2.execute((new StringBuilder()).append("update tblltn_tempoutbl set REMARK = REMARK & ' ' & '").append(a5).append("' WHERE [PART#] = '").append(b5).append("';").toString());
                        } catch (SQLException er) {
                        }
                    }
                st.execute("select * from tblltn_tempoutbl;");
                ResultSet rs3 = st.getResultSet();
                if (rs3 != null) {
                    double gn_p = 0.0D;
                    double depo_p = 0.0D;
                    double gd_p = 0.0D;
                    double high4w = 0.0D;
                    double instock = 0.0D;
                    double shipping = 0.0D;
                    int t12m = 0;
                    int t3msl = 0;
                    double needBuy4 = 0.0D;
                    double need2w = 0.0D;
                    double need2w1 = 0.0D;
                    String bc = "null";
                    String part = "null";
                    String supplier = "null";
                    int n = 0;
                    String beginyr = "null";
                    String endyr = "null";
                    int byr = 0;
                    int eyr = 0;
                    while (rs3.next()) {
                        gn_p = rs3.getDouble("gn_p");
                        depo_p = rs3.getDouble("depo_p");
                        gd_p = rs3.getDouble("gd_p");
                        high4w = rs3.getDouble("high4w");
                        instock = rs3.getDouble("instock");
                        shipping = rs3.getDouble("shipping");
                        t12m = rs3.getInt("t12m");
                        t3msl = rs3.getInt("3msl");
                        supplier = rs3.getString("supplier");
                        n = rs3.getInt("new");
                        beginyr = rs3.getString("beginyr");
                        endyr = rs3.getString("endyr");
                        if (beginyr == null)
                            beginyr = "1900";
                        if (endyr == null)
                            endyr = "1900";
                        byr = Integer.parseInt(beginyr);
                        eyr = Integer.parseInt(endyr);
                        if (supplier == null)
                            supplier = " ";
                        if (instock < 0.0D)
                            instock = 0.0D;
                        bc = dnk.comparePrice(gn_p * 0.97499999999999998D, depo_p, 0.0D, 0.0D, 0.0D, 0.0D, supplier);
                        part = rs3.getString("part#");
                        need2w = dnk.getNeed(t12m);
                        need2w1 = dnk.getNeed1(t12m, byr, eyr, n, t3msl);
                        if (bc.equals("depo") && gn_p > 0.0D && gn_p < depo_p + 1.0D)
                            bc = "gn";
                        try {
                            st2.execute((new StringBuilder()).append("update TBLLTN_tempoutbl set [2w] = ").append(need2w).append(" where [part#] = '").append(part).append("';").toString());
                        } catch (SQLException er) {
                        }
                        if (instock + shipping <= need2w)
                            needBuy4 = need2w1 + (need2w - (instock + shipping));
                        else
                            needBuy4 = 0.0D;
                        if (needBuy4 > 0.0D) {
                            if (bc.equals("gn"))
                                try {
                                    st2.execute((new StringBuilder()).append("update TBLLTN_tempoutbl set gn = ").append(needBuy4).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            else if (bc.equals("depo"))
                                try {
                                    st2.execute((new StringBuilder()).append("update TBLLTN_tempoutbl set depo = ").append(needBuy4).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            else
                                try {
                                    st2.execute((new StringBuilder()).append("update tblltn_tempoutbl set manual=-1 where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                        } else if (needBuy4 >= 0.0D) ;
                    }
                }
                st.execute("UPDATE TBLLTN_TEMPOUTBL SET gn = 0 WHERE T12M <= 2 and gn>0 and gn_p >150;");
                st.execute("UPDATE TBLLTN_TEMPOUTBL SET depo = 0 WHERE T12M <= 2 and depo>0 and depo_p >150;");
                st.execute("DELETE * FROM TBLLTN_TEMPOUTLI2");
                st.execute("INSERT INTO TBLLTN_TEMPOUTLI2([PART#], Supplier, Description, DRSALE, T24m, T12m, [12msl], [9msl], [6msl], [3msl], SHIPPING, InStock, [2W], GN, DEPO, EE, GN_P, DEPO_P, EE_P, GN_MEMO, DEPO_MEMO, EE_MEMO, DNK_MEMO, [GN#], [DEPO#], [EE#], Remark, OEM_NO, PARTLINK, NEW, MANUAL, CAPA, POSITION, DRDATE, gn_k, depo_k, gd_k, ee_k) SELECT [PART#], Supplier, Description, DRSALE, T24m, T12m, [12msl], [9msl], [6msl], [3msl], SHIPPING, InStock, [2W], GN, DEPO, EE, GN_P, DEPO_P, EE_P, GN_MEMO, DEPO_MEMO, EE_MEMO, DNK_MEMO, [GN#], [DEPO#], [EE#], Remark, OEM_NO, PARTLINK, NEW, MANUAL, CAPA, POSITION, DRDATE, gn_k, depo_k, gd_k, ee_k FROM TBLLTN_TEMPOUTLI;");
                st.execute("update tblltn_tempoutli2 a inner join tblltn_tempout b on a.[part#] = b.[part#] set a.onorder = b.onorder where b.onorder > 0;");
                st.execute("select * from tblltn_tempoutli2;");
                ResultSet rs6 = st.getResultSet();
                if (rs6 != null) {
                    int gn = 0;
                    int depo = 0;
                    int gn_k = 0;
                    int depo_k = 0;
                    double gn_p = 0.0D;
                    double depo_p = 0.0D;
                    int gn_buy = 0;
                    int t12m = 0;
                    double gn_a = 0.0D;
                    double depo_a = 0.0D;
                    double gn_b = 0.0D;
                    double depo_b = 0.0D;
                    double gn_c = 0.0D;
                    double depo_c = 0.0D;
                    int gn_m = 0;
                    int depo_m = 0;
                    int s3msl = 0;
                    int s6msl = 0;
                    double instock = 0.0D;
                    int onorder = 0;
                    int shipping = 0;
                    String part = "null";
                    do {
                        if (!rs6.next())
                            break;
                        gn = rs6.getInt("gn");
                        depo = rs6.getInt("depo");
                        gn_k = rs6.getInt("gn_k");
                        depo_k = rs6.getInt("depo_k");
                        gn_p = rs6.getDouble("gn_p");
                        depo_p = rs6.getDouble("depo_p");
                        t12m = rs6.getInt("t12m");
                        s3msl = rs6.getInt("3msl");
                        s6msl = rs6.getInt("6msl");
                        part = rs6.getString("part#");
                        instock = rs6.getDouble("instock");
                        onorder = rs6.getInt("onorder");
                        shipping = rs6.getInt("shipping");
                        if (instock < 0.0D)
                            instock = 0.0D;
                        if (t12m > 2) {
                            if (gn > 0 && gn_k >= 1)
                                try {
                                    gn_m = gn % gn_k;
                                    gn_a = (double) gn / (double) gn_k;
                                    gn_c = (double) gn_m / (double) gn_k;
                                    if (gn_c > 0.59999999999999998D)
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTLI2 SET GN = ").append(Math.ceil(gn_a) * (double) gn_k).append(" where [part#] = '").append(part).append("';").toString());
                                    else if (gn_p <= 7D && Math.ceil(gn_a) * (double) gn_k <= (double) (s3msl + s6msl))
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTLI2 SET GN = ").append(Math.ceil(gn_a) * (double) gn_k).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            if (depo > 0 && depo_k >= 1)
                                try {
                                    depo_m = depo % depo_k;
                                    depo_a = (double) depo / (double) depo_k;
                                    depo_c = (double) depo_m / (double) depo_k;
                                    if (depo_c > 0.59999999999999998D)
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTLI2 SET DEPO = ").append(Math.ceil(depo_a) * (double) depo_k).append(" where [part#] = '").append(part).append("';").toString());
                                    else if (depo_p <= 7D && Math.ceil(depo_a) * (double) depo_k <= (double) (s3msl + s6msl))
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTLI2 SET DEPO = ").append(Math.ceil(depo_a) * (double) depo_k).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                        }
                    } while (true);
                }
                st.execute("DELETE * FROM TBLLTN_TEMPOUTBK2");
                st.execute("INSERT INTO TBLLTN_TEMPOUTBK2([PART#], Supplier, Description, DRSALE, T24m, T12m, [12msl], [9msl], [6msl], [3msl], SHIPPING, InStock, [2W], GN, DEPO, EE, GN_P, DEPO_P, EE_P, GN_MEMO, DEPO_MEMO, EE_MEMO, DNK_MEMO, [GN#], [DEPO#], [EE#], Remark, OEM_NO, PARTLINK, NEW, MANUAL, CAPA, POSITION, DRDATE, gn_k, depo_k, gd_k, ee_k) SELECT [PART#], Supplier, Description, DRSALE, T24m, T12m, [12msl], [9msl], [6msl], [3msl], SHIPPING, InStock, [2W], GN, DEPO, EE, GN_P, DEPO_P, EE_P, GN_MEMO, DEPO_MEMO, EE_MEMO, DNK_MEMO, [GN#], [DEPO#], [EE#], Remark, OEM_NO, PARTLINK, NEW, MANUAL, CAPA, POSITION, DRDATE, gn_k, depo_k, gd_k, ee_k FROM TBLLTN_TEMPOUTBL;");
                st.execute("select * from tblltn_tempoutbk2;");
                ResultSet rs7 = st.getResultSet();
                if (rs7 != null) {
                    int gn = 0;
                    int depo = 0;
                    int gn_k = 0;
                    int depo_k = 0;
                    double gn_p = 0.0D;
                    double depo_p = 0.0D;
                    int gn_buy = 0;
                    int t12m = 0;
                    double gn_a = 0.0D;
                    double depo_a = 0.0D;
                    double gn_b = 0.0D;
                    double depo_b = 0.0D;
                    double gn_c = 0.0D;
                    double depo_c = 0.0D;
                    int gn_m = 0;
                    int depo_m = 0;
                    int s3msl = 0;
                    int s6msl = 0;
                    double instock = 0.0D;
                    int onorder = 0;
                    int shipping = 0;
                    String part = "null";
                    do {
                        if (!rs7.next())
                            break;
                        gn = rs7.getInt("gn");
                        depo = rs7.getInt("depo");
                        gn_k = rs7.getInt("gn_k");
                        depo_k = rs7.getInt("depo_k");
                        gn_p = rs7.getDouble("gn_p");
                        depo_p = rs7.getDouble("depo_p");
                        t12m = rs7.getInt("t12m");
                        s3msl = rs7.getInt("3msl");
                        s6msl = rs7.getInt("6msl");
                        part = rs7.getString("part#");
                        instock = rs7.getDouble("instock");
                        onorder = rs7.getInt("onorder");
                        shipping = rs7.getInt("shipping");
                        if (instock < 0.0D)
                            instock = 0.0D;
                        if (t12m > 2) {
                            if (gn > 0 && gn_k >= 1)
                                try {
                                    gn_m = gn % gn_k;
                                    gn_a = (double) gn / (double) gn_k;
                                    gn_c = (double) gn_m / (double) gn_k;
                                    if (gn_c > 0.59999999999999998D)
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTBK2 SET GN = ").append(Math.ceil(gn_a) * (double) gn_k).append(" where [part#] = '").append(part).append("';").toString());
                                    else if (gn_p <= 7D && Math.ceil(gn_a) * (double) gn_k <= (double) (s3msl + s6msl))
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTBK2 SET GN = ").append(Math.ceil(gn_a) * (double) gn_k).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                            if (depo > 0 && depo_k >= 1)
                                try {
                                    depo_m = depo % depo_k;
                                    depo_a = (double) depo / (double) depo_k;
                                    depo_c = (double) depo_m / (double) depo_k;
                                    if (depo_c > 0.59999999999999998D)
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTBK2 SET DEPO = ").append(Math.ceil(depo_a) * (double) depo_k).append(" where [part#] = '").append(part).append("';").toString());
                                    else if (depo_p <= 7D && Math.ceil(depo_a) * (double) depo_k <= (double) (s3msl + s6msl))
                                        st1.execute((new StringBuilder()).append("UPDATE TBLLTN_TEMPOUTBK2 SET DEPO = ").append(Math.ceil(depo_a) * (double) depo_k).append(" where [part#] = '").append(part).append("';").toString());
                                } catch (SQLException er) {
                                }
                        }
                    } while (true);
                }
            } catch (SQLException er) {
                er.printStackTrace();
            }
            st.close();
            st1.close();
            st2.close();
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error message: "+e);
        }
    }
}
